package com.bootcamp.java;

/**
 * @program: code
 * @description:
 * @author: Keyu li
 * @create: 2021-08-24 19:45
 **/

import java.util.Scanner;

public class ManipulateStudentScores {

    public static void main(String[] args) {
        System.out.println("Please input your score of Math, Chinese, English: ");
        double scoreMath, scoreChinese, scoreEnglish;

        Scanner sc = new Scanner(System.in);
        scoreMath = Double.parseDouble(sc.nextLine());
        scoreChinese = Double.parseDouble(sc.nextLine());
        scoreEnglish = Double.parseDouble(sc.nextLine());

        double averageScore, maxScore, minScore, totalScore;
        // get the total and average score
        totalScore = getTotal(scoreChinese, scoreEnglish, scoreMath);
        averageScore = getAverage(totalScore, 3);

        // get the maximum score
        maxScore = getMaxScore(scoreChinese, scoreEnglish, scoreMath);

        //get the minimum score
        minScore = getMinScore(scoreChinese, scoreEnglish, scoreMath);

        System.out.println("average:" + averageScore + "  min:" + minScore + "  max:" + maxScore + "  total:" + totalScore);
    }

    // get the total score of all three subjects.
    private static double getTotal(double a, double b, double c) {
        return a + b + c;
    }

    //get the average score of the three subject.
    private static double getAverage(double totalScore, int count) {
        return totalScore / count;
    }

    // get the maximum score.
    public static double getMaxScore(double a, double b, double c) {
        double max;
        max = a > b ? a : c;
        max = max > c ? max : c;
        return max;
    }

    //get the minimum score.
    public static double getMinScore(double a, double b, double c) {
        double min;
        min = a < b ? a : c;
        min = min < c ? min : c;
        return min;
    }
}